package beautiful.butterfly.distributed_task_processing_engine.task_manage.task_data_items_processor.task_data_item_data_manager;


import beautiful.butterfly.distributed_task_processing_engine.task_manage.task_processor.Statistics;
import beautiful.butterfly.distributed_task_processing_engine.task_manage.task_processor.TaskProcessorInfo;
import beautiful.butterfly.distributed_task_processing_engine.user_definition.TaskUserDefinition;
import org.apache.zookeeper.data.Stat;

import java.util.List;
import java.util.Map;


public interface ITaskAndTaskProcessorAndTaskDataItemManage
{
    public long zooKeeperCurrentTimeMillis();


    /**
     * <pre>
     * ========================================================================================================================
     * Task
     * ========================================================================================================================
     * </pre>
     */
    public void createTaskUserDefinition(TaskUserDefinition taskUserDefinition) throws Exception;

    public void updateTaskUserDefinition(TaskUserDefinition taskUserDefinition) throws Exception;

    public void pauseTaskUserDefinition(String taskId) throws Exception;

    public void resumeTaskUserDefinition(String taskId) throws Exception;

    public long setTaskNeedReload(String taskId) throws Exception;

    public void clearTask(String taskId) throws Exception;

    public void deleteTask(String taskId) throws Exception;

    public void clearExpireTask(String taskId, double expireDateInternal) throws Exception;

    public List<TaskUserDefinition> getTaskUserDefinitionList() throws Exception;

    public TaskUserDefinition getTaskUserDefinition(String taskId) throws Exception;

    /**
     * <pre>
     * ========================================================================================================================
     * TaskProcessorInfo
     * ========================================================================================================================
     * </pre>
     */
    public void registerTaskProcessorInfoWithSerialNumberAndSetRegisterTrue(TaskProcessorInfo taskProcessorInfo) throws Exception;

    public void deleteTaskProcessor(String taskId, String taskProcessorId) throws Exception;

    public boolean setRegisterFalseIfNodeIsNotExistedOtherwiseUpdateHeartBeatInfo(TaskProcessorInfo taskProcessorInfo) throws Exception;

    public void reportTaskProcessorDealInfo(TaskProcessorInfo taskProcessorInfo, Statistics statistics) throws Exception;

    public int clearExpireTaskProcessor(String taskId, long expireTime) throws Exception;

    public List<TaskProcessorInfo> getTaskProcessorInfoList(String taskId) throws Exception;

    public List<String> getTaskProcessorIdList(String taskId) throws Exception;

    public List<TaskProcessorInfo> getTaskProcessorInfoList(String taskId, String ip, String orderStr)
            throws Exception;


    public List<TaskProcessorInfo> getTaskProcessorInfoListByJvmInstanceId(String jvmInstanceId) throws Exception;

    public boolean isLeaderTaskProcessorId(List<String> taskProcessorIdList, String taskProcessorId);

    public boolean minTaskProcessorIdIsLeaderTaskProcessorId(String taskId) throws Exception;

    public String getMinTaskProcessorId(List<String> taskProcessorIdList);


    public long getTaskProcessors$Stat$Version(String taskId) throws Exception;

    public Map<String, Stat> getTaskProcessorIdToStatMap(String taskId) throws Exception;

    /**
     * <pre>
     * ========================================================================================================================
     * TaskItem
     * ========================================================================================================================
     * </pre>
     */

    public void createTaskItemsWithTaskItemStrings(TaskItem[] taskItems) throws Exception;

    public void releaseOldTaskItemsAndReAllotTaskItemInTaskProcessorIdList(String taskId, String taskProcessorId) throws Exception;

    public int clearTaskItemCurrentTaskProcessorIdNodeWhenNotFoundInTaskProcessorIdList(String taskId, List<String> taskProcessorIdList) throws Exception;

    public void setTaskItemsLeaderTaskProcessorId(String taskId, String taskProcessorId) throws Exception;

    public void updateTaskItem(String taskId, String taskItem, String message) throws Exception;

    public void reallocateTaskItemsTaskCurrentTaskProcessorId(String taskId, List<String> taskProcessorIdList, String currentTaskProcessorId) throws Exception;


    public void releaseTaskItemCurrentTaskProcessorId(String taskId, String taskProcessorId) throws Exception;

    public void deleteTaskItem(String taskId, String taskItem) throws Exception;

    public List<TaskItem> getTaskItemList(String taskId) throws Exception;

    public int getTaskItemListSize(String taskId) throws Exception;

    public List<TaskItemStringAndParameterString> getTaskItemStringAndParameterStringListWithTaskProcessorId(String taskId, String taskProcessorId) throws Exception;


}
